package com.zzyl.mapper;

import com.github.pagehelper.Page;
import com.zzyl.entity.NursingLevel;
import com.zzyl.vo.NursingLevelVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface NursingLevelMapper {
    // 2.1 查询所有护理等级
@Select("select * from zzyl.nursing_level")
    List<NursingLevel> selectAll();

    //* 2.2 新增护理等级前：校验是否重名
    @Select("select  COUNT(*) from zzyl.nursing_level where name = #{name} ")
    int countByName(String name);
    //2.2.1 新增护理项目
    void insert(NursingLevel nursingLevel);
    // 2.2.2 批量新增
    void insertBatch(List<NursingLevel> nursingLevels);


    //2.3 分页查询护理等级NursingLevel
    Page<NursingLevelVo> selectByPage(String name, Integer status);

   // 2.4 根据id查询护理等级Level
    @Select("select COUNT(*) from zzyl.nursing_level where id=#{id}")
    int CountById(Long id);

    NursingLevel findById(Long id);

    // 2.5更新护理等级信息
    void update(NursingLevel nursingLevel);

    // 2.6 删除护理等级信息
    @Delete("delete from zzyl.nursing_level where id=#{id}")
    void delete(Long id);

    // 2.7 启用/禁用护理等级
    @Update("update zzyl.nursing_level  set status = #{status} where id = #{id}")
    void enableOrDisable(Long id, Integer status);

    //2.8 根据nursingPlan计划id查询护理等级
    List<NursingLevel> listAllByPlanIds(List<Long> ids);
}
